/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React, { useEffect } from 'react';
import { Form, message } from 'antd';
import type { FormInstance } from 'antd';
import { ProFormText } from '@ant-design/pro-form';
import { cashBackLastMonthMoney } from '@/services/operatorManagement';

/**
 * 发放模块
 *  */
const DispatchContent: React.FC<{
  form: FormInstance;
  setRewardAmount: (reward_amount: string) => void;
}> = ({ form, setRewardAmount }) => {
  useEffect(() => {
    cashBackLastMonthMoney().then((res) => {
      const { code, data, msg } = res;
      if (code == 0) {
        form.setFieldsValue(data);
        setRewardAmount(data.reward_amount);
      } else {
        message.error(msg);
      }
    });
  }, []);

  return (
    <Form form={form}>
      <ProFormText readonly label='时间' name='batch' />
      <ProFormText readonly label='开启驿站' name='inn_count' />
      <ProFormText
        readonly
        label='返还总金额'
        name='reward_amount'
        fieldProps={{
          suffix: '元',
        }}
      />
    </Form>
  );
};

export default DispatchContent;
